package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.LockAlarm;
import com.example.entity.LockDeviceInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LockAlarmMapper extends BaseMapper<LockAlarm> {

    @Select("SELECT alarm_name, alarm_time, device_id " +
            "FROM lock_alarm la " +
            "WHERE alarm_time = (" +
            "    SELECT MAX(alarm_time) " +
            "    FROM lock_alarm " +
            "    WHERE device_id = la.device_id" +
            ")")
    List<LockAlarm> selectLatestAlarmByDeviceId();

}
